<!DOCTYPE html>
<html>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <title>瓦片图层与地理投影 - WMTS瓦片图层</title>
  <style type="text/css">
    html,
    body {
      margin: 0px;
      height: 100%;
      width: 100%;
    }
    .container {
      width: 100%;
      height: 100%;
    }
  </style>
  <link rel="stylesheet" href="https://unpkg.com/maptalks/dist/maptalks.css" />
  <script
    type="text/javascript"
    src="https://unpkg.com/maptalks/dist/maptalks.js"
  ></script>
  <body>
    <div id="map" class="container"></div>

    <script>
      var url =
        'https://218.106.119.50:6443/geoscene/rest/services/huashan/huashan_ditu3/MapServer/WMTS/1.0.0/WMTSCapabilities.xml'

      maptalks.SpatialReference.loadWMTS(
        url,
        function (err, conf) {
          if (err) {
            throw new Error(err)
          }
          var { urlTemplate } = conf[0]

          // console.log(params)

          // var spatialReference = params.spatialReference
          var tileLayer = new maptalks.TileLayer('tilelayer', {
            urlTemplate,
            spatialReference: {
              projection: 'EPSG:3857'
            }
          })

          var map = new maptalks.Map('map', {
            center: [114.3404041441181, 30.548730054693106],
            zoom: 10,
            baseLayer: tileLayer
          })
        },
        {
          isArcgis: true,
          isSuperMap: false
        }
      )
    </script>
  </body>
</html>
